package mumu.android;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mumu.android.animate.zlib_MyAnimation;
import mumu.android.animate.property.alpha;
import mumu.android.animate.property.animateset;
import mumu.android.animate.property.frame;
import mumu.android.animate.property.rotate;
import mumu.android.animate.property.scale;
import mumu.android.animate.property.translate;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class AnimatePropertyActivity extends ListActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new SimpleAdapter(this, getData(), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
		getListView().setTextFilterEnabled(true);
		// 载入动画
//		Animation animate = AnimationUtils.loadAnimation(this, R.anim.scale_enter);
//		animate.setDuration(1000);
//		getListView().setAnimation(animate);

		WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
		Display display = windowManager.getDefaultDisplay();
		int screenWidth = display.getWidth();
		int screenHeight = display.getHeight();
		getListView();
	}

	protected List getData() {
		List<Map> myData = new ArrayList<Map>();
		addItem(myData, "translatep", new Intent(this, translate.class));
		addItem(myData, "scalep", new Intent(this, scale.class));
		addItem(myData, "rotatep", new Intent(this, rotate.class));
		addItem(myData, "alphap", new Intent(this, alpha.class));
		addItem(myData, "animatesetp", new Intent(this, animateset.class));
		addItem(myData, "framep", new Intent(this, frame.class));
		return myData;
	}

	protected void addItem(List<Map> data, String name, Intent intent) {
		Map<String, Object> temp = new HashMap<String, Object>();
		temp.put("title", name);
		temp.put("intent", intent);
		data.add(temp);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		Map map = (Map) l.getItemAtPosition(position);
		Intent intent = (Intent) map.get("intent");
		startActivity(intent);
	}
}
